<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>3.Array.of与数组创建细节</title>
</head>
<body>
  <script>

    let array = [1,2,3,4];
    console.log(array.length);//4 数组长度

    let hd = ["hdcms"]; //自动以空值补全数组
    hd[3] = "houdunren"; 
    console.log(hd); //['hdcms', empty × 2, 'houdunren']
    console.log(hd[2]); //undefined
    console.log(hd.length);//4

    let cms = new Array(1,23,34,4);
    cms = new Array(6);
    console.log(cms.length);//6
    console.table(cms); //空数组
    console.log(cms[2]);//undefined
    // 使用Array.of 就不会创建空数组
    let arr = Array.of(6); //[6]
    console.log(arr.length);//1
    console.table(arr);


  </script>
</body>
</html>